


#ifndef PF_COLOR_H
#define PF_COLOR_H

#include <QColor>
#include "lx_Export.h"

#include "pf_flags.h"

//! Color defined by layer not entity
//#define C_BY_LAYER     0x00000001
//! Color defined by block not entity
//#define C_BY_BLOCK     0x00000002

/**
 * Color class.
 *

 */
class LX_EXPORT PF_Color: public QColor, public PF_Flags {
public:
    PF_Color() : QColor(), PF_Flags() {}
    PF_Color(int r, int g, int b) : QColor(r, g, b), PF_Flags() {}
    PF_Color(int r, int g, int b, int a) : QColor(r, g, b, a), PF_Flags() {}
    PF_Color(const QColor& c) : QColor(c), PF_Flags() {}
    PF_Color(const PF_Color& c) : QColor(c), PF_Flags() {
        setFlags(c.getFlags());
    }
    PF_Color(unsigned int f) : QColor(), PF_Flags(f) {}

    /** @return A copy of this color without flags. */
    PF_Color stripFlags() const {
        return PF_Color(red(), green(), blue());
    }

    /** @return true if the color is defined by layer. */
    bool isByLayer() const {
        return getFlag(LX_Define::FlagByLayer);
    }

    /** @return true if the color is defined by block. */
    bool isByBlock() const {
        return getFlag(LX_Define::FlagByBlock);
    }


    PF_Color& operator = (const PF_Color& c) {
        setRgb(c.red(), c.green(), c.blue());
        setFlags(c.getFlags());

        return *this;
    }

    bool operator == (const PF_Color& c) const {
        return (red()==c.red() &&
                green()==c.green() &&
                blue()==c.blue() &&
                getFlags()==c.getFlags());
    }

    friend std::ostream& operator << (std::ostream& os, const PF_Color& c) {
        os << " color: " << c.name().toLatin1().data()
        << " flags: " << (c.getFlag(LX_Define::FlagByLayer) ? "LX_Define::FlagByLayer " : "")
        << (c.getFlag(LX_Define::FlagByBlock) ? "LX_Define::FlagByBlock " : "");
        return os;
    }
};

#endif

